<template>
	<view>
		<view class="my-search-container" :style="{'background-color': bgcolor}">
			<view class="my-search-box" :style="{'border-radius': radius + 'rpx'}" @click="searchBoxHandler">
				<uni-icons type="search" size="25"></uni-icons>
				<text class="placeholder">搜索</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "my-search",
		data() {
			return {

			};
		},
		props: {
			// 背景颜色
			bgcolor: {
				type: String,
				default: '#ffaa00'
			},
			// 圆角尺寸
			radius: {
				type: Number,
				// 单位是 rpx
				default: 30
			}
		},
		methods: {
		  // 点击了模拟的 input 输入框
		  searchBoxHandler(query) {
				this.$emit('click')
		  }
		}
	}
</script>

<style lang="scss">
	.my-search-container {
		//移除该属性，用 props 属性控制
		// background-color: #ffaa00;
		height: 40px;
		padding: 0 20rpx;
		display: flex;
		align-items: center;

		.my-search-box {

			background-color: #ffffff;

			//移除该属性，用 props 属性控制
			// border-radius: 30rpx;
			width: 100%;
			display: flex;
			align-items: center;
			justify-content: center;

			.placeholder {

				font-size: 40rpx;
				margin-left: 10rpx;

			}
		}
	}
</style>
